package com.donger.auth.component;

import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * 扩展用户信息 记录当前用户的 id 和 部门
 * @author aeizzz
 * @date 2019-09-01
 */

public class UserDetail extends User {

    @Getter
    private Long id;

    @Getter
    private Long userId;

    @Getter
    private Long deptId;


    /**
     *
     * @param userId
     * @param deptId
     * @param username
     * @param password
     * @param enabled
     * @param accountNonExpired
     * @param credentialsNonExpired
     * @param accountNonLocked
     * @param authorities
     */
    public UserDetail(Long userId, Long deptId, String username, String password,
                      boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked,
                      Collection<? extends GrantedAuthority> authorities) {
        super(username, password,enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
        this.id = userId;
        this.userId = userId;
        this.deptId = deptId;
    }
}
